﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

namespace BaoJian.Control
{
    /// <summary>
    /// 展示最新资讯
    /// </summary>
    public partial class ColType11 : System.Web.UI.UserControl
    {
        public string Region;
        public int PortalID;
        public int Total;
        public int SubTotal;
        public int TitleLen;
        public int MainTitleLen;
        protected void Page_Load(object sender, EventArgs e)
        {
            //TODO:这里的性能需要修改
            if (!Page.IsPostBack)
            {
                LYQ.BLL.Portal bll = new LYQ.BLL.Portal();
                DataTable dt = bll.GetList("PortalID =" + PortalID + " ORDER BY PLevel desc").Tables[0];

                DataRowCollection dr = dt.Rows;           
                System.Text.StringBuilder sb = new System.Text.StringBuilder();
                sb.Append("<h3><a href=\"c.aspx?id=" + dr[0]["DocID"] as string + "\" target=\"_blank\">");                
                if ((dr[0]["DocTitle"] as string).Length > MainTitleLen)
                    sb.Append((dr[0]["DocTitle"] as string).Substring(0, MainTitleLen) + "</a></h3>");
                else
                    sb.Append(dr[0]["DocTitle"] as string + "</a></h3>");
               
                sb.Append("<ul>");
                for (int i = 1; i <= SubTotal; i++)
                {
                    sb.Append("<li><a href=\"col.aspx?p=" + (dr[i]["ColumnID"] as string) +
                        "\" target=\"_blank\">"+(dr[i]["ColumnName"] as string) +
                        "</a> | <a href=\"c.aspx?id=" + dr[i]["DocID"] as string + "\" target=\"_blank\">");

                    string t = (dr[i]["DocTitle"] as string);
                    if(t.Length > TitleLen)
                       sb.Append(t.Substring(0,TitleLen)+"</a></li>");
                    else
                      sb.Append(t+"</a></li>");
                }

                
                sb.Append("</ul>");

                Literal1.Text = sb.ToString();

               
            }
        }
    }
}